package cn.com.smartdevices.bracelet.chart;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.TextPaint;

import com.goodving.guli.R;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.HeartRateInfo;
import com.goodving.guli.view.BitmapDescriptorFactory;
import com.goodving.guli.view.C4220a;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

import cn.com.smartdevices.bracelet.chart.base.BarChart;
import cn.com.smartdevices.bracelet.chart.base.BarChart.BarItem;
import cn.com.smartdevices.bracelet.chart.util.AnimUtil;
import cn.com.smartdevices.bracelet.chart.util.C0804t;

/* renamed from: cn.com.smartdevices.bracelet.chart.A */
public class StatisticChart extends BarChart {
    protected static final int f3806A = 80;
    protected static final int f3807B = 40;
    private static final String f3808a = "Chart.StatisticChart";
    private static final int f3809b = 8000;
    private static final int f3810x = 480;
    private static final float f3811y = 2.5f;
    private static final float f3812z = 1.5f;
    protected int f3813C;
    protected int f3814D;
    protected int f3815E;
    protected int f3816F;
    protected int f3817G;
    protected float f3818H;
    protected float f3819I;
    protected int f3820J;
    protected float f3821K;
    protected int f3822L;
    protected float f3823M;
    protected float f3824N;
    protected C0728F f3825O;
    protected C0725D f3826P;
    protected C0729G f3827Q;
    protected List<DateItem> f3828R;
    protected int f3829S;
    protected int f3830T;
    protected int f3831U;
    protected int f3832V;
    protected int f3833W;
    protected int f3834X;
    protected int f3835Y;
    protected int f3836Z;
    protected int aa;
    protected int ab;
    protected int ac;
    protected int ad;
    protected int ae;
    protected float af;
    protected float ag;
    protected Path ah;
    protected Paint ai;

    public StatisticChart(Context context) {
        super(context);
        float f = 1.0f;

        this.f3818H = -1;
        this.f3819I = -1;
        this.f3831U = -5855549;
        this.f3832V = -8947804;
        this.f3833W = -6842439;
        this.f3834X = -9605731;
        this.f3835Y = -4989455;
        this.f3836Z = -11226145;
        this.aa = -3479563;
        this.ab = -10372640;
        this.ac = -1;
        this.ad = -6694193;
        this.af = 5.0f;
        this.ag = 1.66f;
        this.mXAxis = new C0724C(this, context);
        this.mXAxis.stroke = (int) (C4220a.bf * this.mDensity);
        this.mXAxis.setPadding(this.mPaddingLeft, 0.0f, this.mPaddingRight, 0.0f);
        this.f3825O = new C0728F(this, context);
        this.f3825O.setItemPadding(this.mDensity * 0.83f);
        this.f3825O.setPadding(0.0f, (float) ((int) (this.mDensity * BitmapDescriptorFactory.HUE_ORANGE)), 0.0f, 0.0f);
        this.f3826P = new C0725D(this, context);
        this.f3826P.setItemPadding(this.mDensity * 0.83f);
        this.f3826P.setPadding(0.0f, (float) ((int) (100.0f * this.mDensity)), 0.0f, 0.0f);
        setSleepGoal((int) f3810x);
        this.f3827Q = new C0729G(this, context);
        this.f3827Q.setItemPadding(this.mDensity * 0.83f);
        this.f3827Q.setPadding(0.0f, (float) ((int) (70.0f * this.mDensity)), 0.0f, (float) ((int) (this.mDensity * BitmapDescriptorFactory.HUE_ORANGE)));
        this.f3828R = new ArrayList();
        this.ai = new Paint();
        this.ai.setColor(872415231);
        this.ai.setStyle(Style.STROKE);
        float f2 = 0.3334f * this.mDensity;
        if (f2 >= 1.0f) {
            f = f2;
        }
        this.ai.setStrokeWidth(f);
        this.ai.setPathEffect(new DashPathEffect(new float[]{4.5f * this.mDensity, f3811y * this.mDensity}, 0.0f));
    }

    class C0724C extends XAxis {
        final /* synthetic */ StatisticChart f3842a;
        private Paint f3843b;
        private Paint f3844c;

        public C0724C(StatisticChart c0720a, Context context) {
            super(context);
            this.f3842a = c0720a;

            this.f3843b = new TextPaint(1);
            this.f3843b.setColor(1711276032);
            this.f3844c = new Paint();
            this.f3844c.setColor(0xfff2f2f2);
        }

        private void m8384b(Canvas canvas, RectF rectF, float f, float f2, float f3) {
            int i = HeartRateInfo.HR_EMPTY_VALUE;
            int i2 = 128;
            int c = this.f3842a.ae;
            if (f2 > -1) {
                i = (int) (255.0f * f);
                i2 = (int) (128.0f * f);
            }
            if (f3 > -1) {
                i = (int) ((1.0f - f) * 255.0f);
                i2 = (int) ((1.0f - f) * 128.0f);
            }
            c |= i << 24;
            int i3 = 0 | (i2 << 24);
            if (this.f3842a.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                this.f3843b.setTextSize(15.0f * this.mDensity);
            } else {
                this.f3843b.setTextSize(9.0f * this.mDensity);
            }
            Rect rect = new Rect();
            synchronized (this.f3842a.f3828R) {
                for (DateItem c0721b : this.f3842a.f3828R) {
                    if (c0721b.f3837a <= (this.offset + ((this.f3842a.f3820J - 1) / 2)) + 1 && c0721b.f3837a >= (this.offset + ((this.f3842a.f3820J - 1) / 2)) - this.f3842a.f3820J) {
                        if (this.f3842a.f3829S != PersonInfo.INCOMING_CALL_DISABLE_BIT || c0721b.f3837a == this.offset) {
                            float f4;
                            if (this.f3842a.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                                f4 = this.f3842a.f3823M;
                            } else {
                                f4 = (this.f3842a.f3830T == 1 ? ((rectF.right - this.mPaddingRight) - (((float) (c0721b.f3837a + 1)) * this.f3842a.f3821K)) - this.mScroll : ((rectF.right - this.mPaddingRight) + (((float) (c0721b.f3837a - 1)) * this.f3842a.f3821K)) + this.mScroll) - (((float) ((this.f3842a.f3820J - 1) / 2)) * this.f3842a.f3821K);
                            }
                            float f5 = rectF.top;
                            if (c0721b.f3837a == this.offset) {
                                this.f3843b.setColor(c);
                            } else {
                                this.f3843b.setColor(i3);
                            }
                            this.f3843b.getTextBounds(c0721b.f3838b, 0, c0721b.f3838b.length(), rect);
                            canvas.drawText(c0721b.f3838b, f4 + ((this.f3842a.f3821K - ((float) rect.width())) / 2.0f), f5 + (((float) (this.stroke + rect.height())) / 2.0f), this.f3843b);
                        }
                    }
                }
            }
        }

        protected void doScroll(float f) { //m8385a
            this.offset = -Math.round(this.mScroll / this.f3842a.f3821K);
        }

        public void m8386a(Canvas canvas, float f, float f2, float f3) {
            m8387a(canvas, this.mRect, f, f2, f3);
        }

        public void m8387a(Canvas canvas, RectF rectF, float f, float f2, float f3) {
            if (this.f3842a.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                canvas.drawRect(rectF, this.f3844c);
            }
            m8384b(canvas, rectF, f, f2, f3);
        }
    }

    class C0725D extends BarChart {
        final /* synthetic */ StatisticChart f3845a;

        public C0725D(StatisticChart c0720a, Context context) {
            super(context);
            this.f3845a = c0720a;

        }

        protected float itemWidth (RectF rectF, BarItem c0726c) { // m8388a
            return this.f3845a.f3821K - (this.mItemPadding * 2.0f);
        }

        public void draw(Canvas canvas, float f, float f2, float f3, float f4, float f5) { // m8389a
            synchronized (this.mItems) {
                for (BarItem c0726c : this.mItems) {
                    if (c0726c.f3886e) {
                        ((StatisticBarItem) c0726c).draw(canvas, f, f2, f3, f4, f5);
                    }
                }
            }
        }

        protected boolean m8390a(BarItem c0726c) { //TBD
            int i = this.f3845a.mXAxis.offset;
            return c0726c.f3884c >= (i - this.f3845a.f3822L) + -1 && c0726c.f3884c <= (i + this.f3845a.f3822L) + 1;
        }

        protected float itemOffsetX (RectF rectF, BarItem c0726c) { //m8391c
            return this.f3845a.f3830T == 1 ? (((float) (this.f3845a.f3822L - c0726c.f3884c)) * this.f3845a.f3821K) - this.f3845a.mXAxis.getScroll() : (((float) (this.f3845a.f3822L + c0726c.f3884c)) * this.f3845a.f3821K) + this.f3845a.mXAxis.getScroll();
        }
    }

    class C0728F extends C0725D {
        final /* synthetic */ StatisticChart f3888b;
        protected float f3889x;
        protected int f3890y;

        public C0728F(StatisticChart c0720a, Context context) {
            super(c0720a, context);
            this.f3888b = c0720a;

            this.f3890y = 10;
        }

        protected void onRectChanged (RectF rectF) { // m8458a
            super.onRectChanged(rectF);
            if (rectF != null) {
                this.f3889x = C0804t.m8822a(this.mMaxItemValue, (rectF.height() - this.mPaddingTop) - this.mPaddingBottom, this.f3890y);
            }
        }

        protected float itemHeight (RectF rectF, BarItem c0726c) { // m8459b
            return c0726c.f3883b >= this.mMaxItemValue ? (rectF.height() - this.mPaddingTop) - this.mPaddingBottom : C0804t.m8823a(this.mMaxItemValue, c0726c.f3883b, this.f3889x, this.f3890y);
        }
    }

    class C0729G extends C0725D {
        final /* synthetic */ StatisticChart f3891b;
        private Path f3892x;
        private Paint f3893y;

        public C0729G(StatisticChart c0720a, Context context) {
            super(c0720a, context);
            this.f3891b = c0720a;

            this.f3892x = new Path();
            this.f3893y = new Paint(1);
            this.f3893y.setStyle(Style.STROKE);
            this.f3893y.setStrokeWidth(c0720a.ag * this.mDensity);
            this.f3893y.setColor(c0720a.ad);
        }

        private void m8460a(Canvas canvas, Paint paint, PointF[] pointFArr, PointF[] pointFArr2) {
            int i = 0;
            float[] fArr = new float[(pointFArr.length * 2)];
            int i2 = 0;
            for (PointF pointF : pointFArr) {
                fArr[i2] = pointF.x;
                i2++;
                fArr[i2] = pointF.y;
                i2++;
            }
            paint.setColor(0xff00ff00);
            canvas.drawPoints(fArr, paint);
            float[] fArr2 = new float[(pointFArr2.length * 2)];
            int length = pointFArr2.length;
            int i3 = 0;
            while (i < length) {
                PointF pointF2 = pointFArr2[i];
                fArr2[i3] = pointF2.x;
                i3++;
                fArr2[i3] = pointF2.y;
                i3++;
                i++;
            }
            canvas.drawPoints(fArr2, paint);
        }

        private void m8461a(Canvas canvas, Path path, Paint paint, PointF[] pointFArr) {
            int i = 0;
            PointF pointF = pointFArr[0];
            path.moveTo(pointF.x, pointF.y);
            while (i < pointFArr.length - 2) {
                pointF = pointFArr[i];
                PointF pointF2 = pointFArr[i + 1];
                path.quadTo(pointF.x, pointF.y, (pointF.x + pointF2.x) / 2.0f, (pointF.y + pointF2.y) / 2.0f);
                i++;
            }
            PointF pointF3 = pointFArr[pointFArr.length - 2];
            pointF = pointFArr[pointFArr.length - 1];
            path.quadTo(pointF3.x, pointF3.y, pointF.x, pointF.y);
            paint.setColor(0xff00ffff);
            canvas.drawPath(path, paint);
        }

        private void m8462a(Canvas canvas, Path path, RectF rectF, Paint paint) {
            float[] fArr;
            PathMeasure pathMeasure = new PathMeasure(path, false);
            float length = pathMeasure.getLength();
            int centerX = (int) rectF.centerX();
            int i = (int) length;
            int i2 = 0;
            while (i2 <= i && ((float) i2) <= length && ((float) i) <= length) {
                int i3 = i2 + ((i - i2) >> 1);
                fArr = new float[2];
                pathMeasure.getPosTan((float) i3, fArr, null);
                if (centerX == ((int) fArr[0])) {
                    break;
                } else if (((float) centerX) > fArr[0]) {
                    i = i3 - 1;
                } else {
                    i2 = i3 + 1;
                }
            }
            fArr = null;
            if (fArr != null) {
                canvas.drawLine(rectF.centerX(), rectF.bottom, rectF.centerX(), fArr[1], paint);
            }
        }

        private float[] m8463a(float[] fArr) {
            int length = fArr.length;
            float[] fArr2 = new float[length];
            float[] fArr3 = new float[length];
            float f = 2.0f;
            fArr2[0] = fArr[0] / 2.0f;
            int i = 1;
            while (i < length) {
                fArr3[i] = 1.0f / f;
                float f2 = (i < length + -1 ? 4.0f : 3.5f) - fArr3[i];
                fArr2[i] = (fArr[i] - fArr2[i - 1]) / f2;
                i++;
                f = f2;
            }
            for (int i2 = 1; i2 < length; i2++) {
                int i3 = (length - i2) - 1;
                fArr2[i3] = fArr2[i3] - (fArr3[length - i2] * fArr2[length - i2]);
            }
            return fArr2;
        }

        private PointF[][] m8464a(PointF[] pointFArr, PointF[] pointFArr2, PointF[] pointFArr3) {
            if (pointFArr == null) {
                throw new IllegalArgumentException("knots");
            }
            int length = pointFArr.length - 1;
            if (length < 1) {
                throw new IllegalArgumentException("At least two knot points required");
            } else if (length == 1) {
                PointF[] pointFArr4 = new PointF[]{new PointF()};
                pointFArr4[0].x = ((2.0f * pointFArr[0].x) + pointFArr[1].x) / 3.0f;
                pointFArr4[0].x = ((2.0f * pointFArr[0].y) + pointFArr[1].y) / 3.0f;
                PointF[] pointFArr5 = new PointF[]{new PointF()};
                pointFArr5[0].x = (2.0f * pointFArr4[0].x) - pointFArr[0].x;
                pointFArr5[0].y = (2.0f * pointFArr4[0].y) - pointFArr[0].y;
                PointF[][] r0 = (PointF[][]) Array.newInstance(PointF.class, new int[]{2, 1});
                r0[0] = pointFArr4;
                r0[1] = pointFArr5;
                return r0;
            } else {
                int i;
                float[] fArr = new float[length];
                for (i = 1; i < length - 1; i++) {
                    fArr[i] = (4.0f * pointFArr[i].x) + (2.0f * pointFArr[i + 1].x);
                }
                fArr[0] = pointFArr[0].x + (2.0f * pointFArr[1].x);
                fArr[length - 1] = ((8.0f * pointFArr[length - 1].x) + pointFArr[length].x) / 2.0f;
                float[] a = m8463a(fArr);
                for (i = 1; i < length - 1; i++) {
                    fArr[i] = (4.0f * pointFArr[i].y) + (2.0f * pointFArr[i + 1].y);
                }
                fArr[0] = pointFArr[0].y + (2.0f * pointFArr[1].y);
                fArr[length - 1] = ((8.0f * pointFArr[length - 1].y) + pointFArr[length].y) / 2.0f;
                fArr = m8463a(fArr);
                PointF[] pointFArr6 = new PointF[length];
                PointF[] pointFArr7 = new PointF[length];
                for (i = 0; i < length; i++) {
                    pointFArr6[i] = new PointF(a[i], fArr[i]);
                    if (i < length - 1) {
                        pointFArr7[i] = new PointF((2.0f * pointFArr[i + 1].x) - a[i + 1], (2.0f * pointFArr[i + 1].y) - fArr[i + 1]);
                    } else {
                        pointFArr7[i] = new PointF((pointFArr[length].x + a[length - 1]) / 2.0f, (pointFArr[length].y + fArr[length - 1]) / 2.0f);
                    }
                }
                PointF[][]r0 = (PointF[][]) Array.newInstance(PointF.class, new int[]{2, length});
                r0[0] = pointFArr6;
                r0[1] = pointFArr7;
                return r0;
            }
        }

        private void m8465b(Canvas canvas, Path path, Paint paint, PointF[] pointFArr) {
            PointF[][] a = m8464a(pointFArr, null, null);
            PointF[] pointFArr2 = a[0];
            PointF[] pointFArr3 = a[1];
            PointF pointF = pointFArr[0];
            path.moveTo(pointF.x, pointF.y);
            for (int i = 0; i < pointFArr.length - 1; i++) {
                PointF pointF2 = pointFArr2[i];
                PointF pointF3 = pointFArr3[i];
                PointF pointF4 = pointFArr[i + 1];
                path.cubicTo(pointF2.x, pointF2.y, pointF3.x, pointF3.y, pointF4.x, pointF4.y);
            }
            canvas.drawPath(path, paint);
        }

        public void m8466a(Canvas canvas, float f, float f2, float f3, float f4, float f5) {
            synchronized (this.mItems) {
                this.f3892x.rewind();
                List<BarItem> arrayList = new ArrayList();
                List arrayList2 = new ArrayList();
                for (int i = 0; i < this.mItems.size(); i++) {
                    BarItem c0726c = (BarItem) this.mItems.get(i);
                    if (c0726c.f3886e) {
                        RectF m = c0726c.getRect();
                        float centerX = m.centerX();
                        float f6 = f2 == -1 ? m.top : f2;
                        float f7 = f3 == -1 ? m.top : f3;
                        if (f2 == -1 && f3 == -1) {
                            f6 = this.mDensity * 185.0f;
                            f7 = m.top;
                        }
                        arrayList2.add(new PointF(centerX, ((f7 - f6) * f) + f6));
                        arrayList.add(c0726c);
                    }
                }
                if (arrayList2.size() > 2) {
                    m8465b(canvas, this.f3892x, this.f3893y, (PointF[]) arrayList2.toArray(new PointF[arrayList2.size()]));
                } else if (arrayList2.size() == 2 && this.mItems.size() == 2) {
                    PointF pointF = (PointF) arrayList2.get(0);
                    this.f3892x.moveTo(pointF.x, pointF.y);
                    pointF = (PointF) arrayList2.get(1);
                    this.f3892x.lineTo(pointF.x, pointF.y);
                    canvas.drawPath(this.f3892x, this.f3893y);
                }
                for (BarItem c0726c2 : arrayList) {
                    ((C0730H) c0726c2).draw(canvas, f, f2, f3, f4, f5);
                }
            }
        }

        protected boolean m8467a(BarItem c0726c) {
            int i = this.f3891b.mXAxis.offset;
            return c0726c.f3884c >= ((i - this.f3891b.f3822L) + -1) + -2 && c0726c.f3884c <= ((i + this.f3891b.f3822L) + 1) + 2;
        }

        protected float m8468b(RectF rectF, BarItem c0726c) {
            return (((float) (c0726c.f3883b - this.f3801e)) / ((float) (this.mMaxItemValue - this.f3801e))) * ((rectF.height() - this.mPaddingTop) - this.mPaddingBottom);
        }

        public void m8469e() {
            int j = this.f3891b.f3814D;
            int k = this.f3891b.f3815E;
            int i = j;
            j = k;
            for (BarItem c0726c : this.mItems) {
                if (m8467a(c0726c)) {
                    if (c0726c.f3883b > i) {
                        int i2 = (((c0726c.f3883b - i) / 30) + 1) * 30;
                        i += i2;
                        j -= i2;
                    }
                    if (c0726c.f3883b < j) {
                        k = (((j - c0726c.f3883b) / 30) + 1) * 30;
                        i += k;
                        k = j - k;
                        j = i;
                        i = j;
                        j = k;
                    }
                }
                k = j;
                j = i;
                i = j;
                j = k;
            }
            if (i != this.mMaxItemValue) {
                this.f3891b.f3819I = -1;
                this.f3891b.ah = null;
                setMaxItemValue(i);
                setNeedRealign(true);
            }
            if (j != this.f3801e) {
                this.f3891b.f3819I = -1;
                this.f3891b.ah = null;
                m8325j(j);
                setNeedRealign(true);
            }
            super.notifyChanged();
        }
    }

    public class DateItem  { // C0721B
        int f3837a;
        String f3838b;
    }

    public class StatisticBarItem  extends BarItem { //C0727E
        public int f3887a;

        public StatisticBarItem(Context context) {
            super(context);
        }

        public void draw(Canvas canvas, float f, float f2, float f3, float f4, float f5) { // m8454a
            draw(canvas, this.mRect, f, f2, f3, f4, f5);
        }

        protected void draw(Canvas canvas, RectF rectF, float f, float f2, float f3, float f4, float f5) { // m8455a
            if (this.f3886e || rectF.height() != 0.0f) {
                float f6;
                float f7;
                float f8;
                float f9;
                Paint paint;
                if (f2 == -1) {
                    f6 = 0.0f;
                    f7 = 0.0f;
                    f8 = f5;
                    f9 = f3;
                } else {
                    f9 = rectF.height();
                    f8 = rectF.height() * (((float) this.f3887a) / ((float) this.f3883b));
                    f7 = f4;
                    f6 = f2;
                }
                if (f3 == -1) {
                    f9 = rectF.height();
                    f8 = rectF.height() * (((float) this.f3887a) / ((float) this.f3883b));
                } else if (f3 == -2.0f) {
                    f6 = rectF.height();
                    f7 = (((float) this.f3887a) / ((float) this.f3883b)) * rectF.height();
                    f9 = 0.0f;
                    f8 = 0.0f;
                } else {
                    f6 = rectF.height();
                    f7 = rectF.height() * (((float) this.f3887a) / ((float) this.f3883b));
                }
                f6 += (f9 - f6) * f;
                float f10 = f7 + ((f8 - f7) * f);
                float width = rectF.width();
                f7 = (rectF.width() / 2.0f) + rectF.left;
                f9 = rectF.bottom;
                float f11 = rectF.bottom - f6;
                mRenderer.f3958c.setStrokeWidth(width);
                StatisticChart c0720a = (StatisticChart) getParent();
                if (this.f3887a < 0 || this.f3883b <= 0) {
                    paint = null;
                } else {
                    Paint paint2 = new Paint();
                    paint2.setStrokeWidth(width);
                    paint = paint2;
                }
                int i = 0;
                int i2 = 0;
                if (c0720a.f3829S == 16) {
                    i = c0720a.f3831U;
                    i2 = c0720a.f3832V;
                } else if (c0720a.f3829S == 1) {
                    i = c0720a.f3835Y;
                    i2 = c0720a.f3836Z;
                } else if (c0720a.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                    i = -6042459;
                    i2 = -9384843;
                }
                float f12 = c0720a.f3823M;
                float n = c0720a.f3824N;
                int y;
                if (rectF.right < f12 || rectF.left > n) {
                    int i3;
                    int x = c0720a.ab;
                    int x2 = c0720a.ab;
                    int y2 = c0720a.f3834X;
                    y = c0720a.f3834X;
                    if (f2 > -1) {
                        x = c0720a.aa;
                        y2 = c0720a.f3833W;
                        i3 = i;
                    } else {
                        i3 = i2;
                    }
                    if (f3 > -1) {
                        y = c0720a.aa;
                        i2 = i;
                        i = c0720a.f3833W;
                    } else {
                        i = y;
                        y = x2;
                    }
                    if (i3 != i2) {
                        i2 = C0804t.m8826a(i3, i2, f);
                    }
                    mRenderer.f3958c.setColor(i2);
                    if (paint != null) {
                        if (c0720a.f3829S == 16) {
                            paint.setColor(y2 == i ? i : C0804t.m8826a(y2, i, f));
                        } else if (c0720a.f3829S == 1) {
                            paint.setColor(x == y ? y : C0804t.m8826a(x, y, f));
                        }
                    }
                } else {
                    float f13 = 0.0f;

                    if (rectF.left < f12) {
                        f13 = f12 - rectF.left;
                    } else if (rectF.right > n) {
                        f13 = rectF.right - n;
                    }
                    f12 = rectF.width() / 2.0f;
                    if (f13 >= f12) {
                        i = c0720a.ab;
                        y = i2;
                        i2 = c0720a.f3834X;
                    } else if (f13 == 0.0f) {
                        y = c0720a.aa;
                        i2 = c0720a.f3833W;
                        int i4 = y;
                        y = i;
                        i = i4;
                    } else {
                        f12 = f13 / f12;
                        y = C0804t.m8826a(i, i2, f12);
                        i = C0804t.m8826a(c0720a.aa, c0720a.ab, f12);
                        i2 = C0804t.m8826a(c0720a.f3833W, c0720a.f3834X, f12);
                    }
                    mRenderer.f3958c.setColor(y);
                    if (paint != null) {
                        if (c0720a.f3829S == 16) {
                            paint.setColor(i2);
                        } else if (c0720a.f3829S == 1) {
                            paint.setColor(i);
                        }
                    }
                }
                canvas.drawLine(f7, f9, f7, f11, mRenderer.f3958c);
                if (paint != null) {
                    canvas.drawLine(f7, f9, f7, rectF.bottom - f10, paint);
                }
            }
        }
    }

    private void m8332b(Canvas canvas) {
        float f;
        int i;
        if (this.f3829S == 1) {
            f = this.f3818H;
            if (f < 0.0f) {
                RectF m = this.f3825O.getRect();
                i = this.f3825O.getMaxItemValue();
                f = m.bottom;
                if (i > 0 && this.f3825O.f3889x > 0.0f) {
                    f -= C0804t.m8823a(i, this.f3816F, this.f3825O.f3889x, this.f3825O.f3890y);
                }
                this.f3818H = f;
            }
        } else if (this.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            f = this.f3819I;
            if (f < 0.0f) {
                RectF m2 = this.f3827Q.getRect();
                i = this.f3827Q.getMaxItemValue();
                int j = this.f3827Q.m8324j();
                f = m2.bottom - this.f3827Q.getPaddingBottom();
                if (j > 0 && i > 0 && this.f3817G >= j && this.f3817G <= i) {
                    f -= ((m2.height() - this.f3827Q.getPaddingTop()) - this.f3827Q.getPaddingBottom()) * (((float) (this.f3817G - j)) / ((float) (i - j)));
                }
                this.f3819I = f;
            }
        } else {
            f = 0.0f;
        }
        if (this.ah == null) {
            this.ah = new Path();
            this.ah.moveTo(this.mRect.left, f);
            this.ah.lineTo(this.mRect.right, f);
        }
        canvas.drawPath(this.ah, this.ai);
    }

    private void m8334c(Canvas canvas) {
        RectF rectF = new RectF(this.mRect);
        rectF.left = this.mRect.centerX() - (this.f3821K / 2.0f);
        rectF.right = this.mRect.centerX() + (this.f3821K / 2.0f);
        rectF.bottom = this.mXAxis.getRect().top + 0.5f;
        Paint paint = new Paint();
        Path path = new Path();
        path.moveTo(rectF.left + ((rectF.width() - (this.mDensity * 12.0f)) / 2.0f), rectF.bottom);
        path.lineTo(rectF.centerX(), rectF.bottom - (6.0f * this.mDensity));
        path.lineTo(rectF.right - ((rectF.width() - (this.mDensity * 12.0f)) / 2.0f), rectF.bottom);
        path.close();
        Paint paint2 = new Paint(1);
        paint2.setStyle(Style.FILL);
        paint2.setColor(0xfff2f2f2);
        canvas.drawPath(path, paint2);
    }

    private void m8339g() {
        if (this.f3820J > 0 && this.mRect != null) {
            this.f3821K = ((this.mRect.width() - this.mPaddingLeft) - this.mPaddingRight) / ((float) this.f3820J);
            GuliLog.tracePrintInfo(f3808a, "Update Bar Item Width : " + this.f3821K);
            this.f3823M = (float) ((int) (this.mRect.centerX() - (this.f3821K / 2.0f)));
            this.f3824N = (float) ((int) (this.mRect.centerX() + (this.f3821K / 2.0f)));
        }
    }

    private void m8344k(int i) {
        this.f3814D = i + 60;
        this.f3815E = i - 60;
        if (this.f3814D > 1500) {
            this.f3814D = 1500;
        }
        if (this.f3815E < 0) {
            this.f3815E = 0;
        }
        GuliLog.tracePrintInfo(f3808a, "MaxValue : " + this.f3814D);
        GuliLog.tracePrintInfo(f3808a, "MinValue : " + this.f3815E);
        this.f3827Q.setMaxItemValue(this.f3814D);
        this.f3827Q.m8325j(this.f3815E);
    }

    private void m8346l(int i) {
        this.f3814D = AnimUtil.f4064d;
        this.f3815E = 400;
        this.f3827Q.setMaxItemValue(this.f3814D);
        this.f3827Q.m8325j(this.f3815E);
        if (i > 0) {
            int i2;
            if (i > this.f3814D) {
                i2 = (((i - this.f3814D) / 100) + 1) * 100;
                this.f3814D += i2;
                this.f3815E = i2 + this.f3815E;
            } else if (i < this.f3815E) {
                i2 = (((this.f3815E - i) / 100) + 1) * 100;
                this.f3814D -= i2;
                this.f3815E -= i2;
            }
            GuliLog.tracePrintInfo(f3808a, "MaxValue : " + this.f3814D);
            GuliLog.tracePrintInfo(f3808a, "MinValue : " + this.f3815E);
            this.f3827Q.setMaxItemValue(this.f3814D);
            this.f3827Q.m8325j(this.f3815E);
        }
    }

    public int m8361a() {
        return this.f3820J;
    }

    protected void  doScroll (float f) { // m8362a
        if (this.mLoadCallback != null) {
            int i;
            int i2 = this.mXAxis.offset;
            this.mXAxis.scrollTo(this.mScroll);
            int i3 = this.mXAxis.offset;
            Object obj = null;
            int i4;
            int i5;
            if (f < 0.0f) {
                if (i3 == i2 && this.mScroll / this.f3821K < ((float) i3)) {
                    i3++;
                }
                i4 = i2;
                for (i5 = i3; i5 > i2; i5--) {
                    if (!this.mLoadCallback.hasData(i5)) {
                        obj = 1;
                        i4 = i5;
                    }
                }
                i = i4 - 1;
            } else {
                if (i3 == i2 && (-(this.mScroll / this.f3821K)) < ((float) i3)) {
                    i3--;
                }
                i4 = i2;
                for (i5 = i3; i5 < i2; i5++) {
                    if (!this.mLoadCallback.hasData(i5)) {
                        obj = 1;
                        i4 = i5;
                    }
                }
                i = i4 + 1;
            }
            if (obj != null) {
                this.mScroll = ((float) (-i)) * this.f3821K;
                this.mXAxis.scrollTo(this.mScroll);
                int i6 = this.mXAxis.offset;
                ((C0733M) this.mLoadCallback).m8481a();
                i3 = i6;
            }
            if (i3 != i2) {
                this.mLoadCallback.loadData(i3);
            }
        }
    }

    public void setStepGoal (int i) { //m8363a
        int i2 = f3809b;
        if (i >= f3809b) {
            i2 = i;
        }
        this.f3825O.setMaxItemValue((int) (((float) i2) * f3811y));
        this.f3816F = i;
        this.f3818H = -1;
        this.ah = null;
    }

    public void draw (Canvas canvas, float f, float f2, float f3, float f4, float f5, boolean z) { //m8364a
        ((C0724C) this.mXAxis).m8386a(canvas, f, f2, f3);
        if (!z) {
            if (this.f3829S == 16) {
                this.f3826P.draw(canvas, f, f2, f3, f4, f5);
            } else if (this.f3829S == 1) {
                m8332b(canvas);
                this.f3825O.draw(canvas, f, f2, f3, f4, f5);
            } else if (this.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                if (this.f3817G > 0) {
                    m8332b(canvas);
                }
                this.f3827Q.m8466a(canvas, f, f2, f3, f4, f5);
            }
        }
        if (!z || this.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            m8334c(canvas);
        }
    }

    public void onRectChanged (RectF rectF) { // m8365a
        super.onRectChanged(rectF);
        m8339g();
        RectF m = this.mXAxis.getRect();
        RectF rectF2 = new RectF(rectF);
        rectF2.left = rectF.left + this.mPaddingLeft;
        rectF2.right = rectF.right - this.mPaddingRight;
        rectF2.bottom = m.top;
        this.f3825O.setRect(rectF2);
        rectF2 = new RectF(rectF);
        rectF2.left = rectF.left + this.mPaddingLeft;
        rectF2.right = rectF.right - this.mPaddingRight;
        rectF2.bottom = m.top;
        this.f3826P.setRect(rectF2);
        rectF2 = new RectF(rectF);
        rectF2.left = rectF.left + this.mPaddingLeft;
        rectF2.right = rectF.right - this.mPaddingRight;
        rectF2.bottom = m.top;
        this.f3827Q.setRect(rectF2);
    }

    public float getBarItemWidth () { // m8366b
        return this.f3821K;
    }

    public int offsetScrolled (float f) { // m8367b
        float centerX = this.mRect.centerX() - (this.f3821K / 2.0f);
        float centerX2 = this.mRect.centerX() + (this.f3821K / 2.0f);
        return f < centerX ? -Math.round(((float) (((int) ((centerX - f) / this.f3821K)) + 1)) * this.f3821K) : f > centerX2 ? -Math.round(((float) ((-((int) ((f - centerX2) / this.f3821K))) - 1)) * this.f3821K) : 0;
    }

    public void setSleepGoal (int i) { // m8368b
        this.f3826P.setMaxItemValue((int) (((float) i) * f3812z));
    }

    public void fillStepData (List<StatisticBarItem> list) { // m8369b
        this.f3825O.fillItems(list);
    }

    public int justified () { // m8370c
        int i = (int) (this.mScroll % this.f3821K);
        if (((float) Math.abs(i)) <= this.f3821K / 2.0f) {
            return i;
        }
        if (i > 0) {
            return (int) (-(this.f3821K - ((float) i)));
        }
        return (int) (((float) i) + this.f3821K);
    }

    public void setWeightBase (int i) { // m8371c
        m8344k(i);
        GuliLog.tracePrintInfo(f3808a, "WeightBase : " + i);
        this.f3813C = i;
    }

    public void fillSleepData (List<StatisticBarItem> list) { // m8372c
        this.f3826P.fillItems(list);
    }

    public int itemOffset () { // m8373d
        return this.mXAxis.offset;
    }

    public void setWeightGoal (int i) { // m8374d
        GuliLog.tracePrintInfo(f3808a, "WeightGoal : " + i);
        this.f3817G = i;
        this.f3819I = -1;
        this.ah = null;
    }

    public void fillWeightData(List<C0730H> list) { // m8375d
        this.f3827Q.fillItems(list);
    }

    public void notifyChanged () { // m8376e
        if (this.f3829S == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            this.f3827Q.m8469e();
            return;
        }
        this.f3825O.notifyChanged();
        this.f3826P.notifyChanged();
    }

    public void m8377e(int i) {
        this.f3829S = i;
        int i2 = 0;
        Resources resources = getContext().getResources();
        switch (i) {
            case 1 /*1*/:
                i2 = resources.getColor(R.color.bg_mode_step);
                break;
            case 16 /*16*/:
                i2 = resources.getColor(R.color.bg_mode_sleep);
                break;
            case PersonInfo.INCOMING_CALL_DISABLE_BIT /*256*/:
                i2 = resources.getColor(R.color.bg_mode_weight);
                break;
        }
        this.ae = i2 & 0xffffff;
    }

    public void fillDates (List<DateItem> list) { // m8378e
        synchronized (this.f3828R) {
            this.f3828R.clear();
            this.f3828R.addAll(list);
        }
    }

    public void clearData () { // m8379f
        offsetTo(0);
    }

    public void m8380f(int i) {
        this.f3830T = i;
    }

    public void updateBarItemCount (int i) { // m8381g
        this.f3820J = i;
        GuliLog.tracePrintInfo(f3808a, "Update Bar Item Count : " + i);
        this.f3822L = (this.f3820J - 1) / 2;
        m8339g();
    }

    public void offsetTo (int i) { // m8382h
        this.mScroll = ((float) i) * this.f3821K;
        this.mXAxis.scrollTo(this.mScroll);
    }
}
